#include "replaycapcmdframe.h"

using namespace IGBTProtocol;

ReplayCapCmdFrame::ReplayCapCmdFrame()
    : CmdFrame()
{
    _capturePeriodUs = 100;
    _replayIntervalS = 300;
}

ReplayCapCmdFrame::ReplayCapCmdFrame(unsigned short capturePeriodUs, unsigned short replayIntervalS)
    : CmdFrame(Cmd_TimerCap, 5)
{
    _capturePeriodUs = capturePeriodUs;
    _replayIntervalS = replayIntervalS;
}

unsigned int ReplayCapCmdFrame::frame(QByteArray* buff, bool tail)
{
    Q_UNUSED(tail);

    CmdFrame::frame(buff);

    buff->append(_capturePeriodUs & 0x00ff);
    buff->append(_capturePeriodUs >> 8);

    buff->append(_replayIntervalS & 0x00ff);
    buff->append(_replayIntervalS >> 8);

    buff->append(calcCRC(buff,_dataSize + 9));
    return 10+_dataSize;
}
